package com.boot.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.boot.domain.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.boot.constant.SystemConstants;
import com.boot.resp.Response;
import com.boot.service.OrgService;

/**
 * @author wwj
 * @author pan zhang
 */

@RestController
@RequestMapping(value = "/screenfirst")
public class ScreenFirstController {

    @Resource
    private OrgService orgServiceImpl;

    @RequestMapping("/basicRemarkData")
    public Response<Object> basicRemarkData(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "首页视频图片描述查询接口");

        List<Profile> entityList = orgServiceImpl.getProfile();

        response.setData(entityList.get(0));
        return response;
    }

    @RequestMapping("/basicData")
    public Response<Object> basicData(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "基础数据查询接口");

        List<Entity> entityList = orgServiceImpl.getBasicData("jgNum,cyNum,jyNum,sysNum,hyNum,kyNum,zrrsNum,frNum".split(","));
        Map<String,String> allNumList = new HashMap<String,String>(8);

        for(Entity entity: entityList){
            allNumList.put(entity.getName(),entity.getNum());
        }

        response.setData(allNumList);
        return response;
    }

    @RequestMapping("/countyBasicData")
    public Response<Object> countyBasicData(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "县市基础数据查询接口");
        String[] str = {request.getParameter("county")+"_jg",request.getParameter("county")+"_xz",request.getParameter("county")+"_zx",request.getParameter("county")+"_jyjg"};
        List<Entity> entityList = orgServiceImpl.getBasicData(str);
        Map<String,String> allNumList = new HashMap<String,String>(4);

        for(Entity entity: entityList){
            allNumList.put(entity.getName(),entity.getNum());
        }

        response.setData(allNumList);
        return response;
    }

    @RequestMapping(value = "/inspectionCenter")
    public Response<Object> inspectionCenter(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "衡水市检验中心总数（渗透）");
        List<InspectionByType> inspectionByTypeList  = orgServiceImpl.getInspectionByType(SystemConstants.LAB_TYPE_INSPECTION);
        response.setData(inspectionByTypeList);
        return response;
    }

    @RequestMapping(value = "/laboratory")
    public Response<Object> laboratory(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "衡水市实验室总数（渗透）");
        List<LaboratoryByType> laboratoryByTypeList  = orgServiceImpl.getLaboratoryByType(SystemConstants.LAB_TYPE_LABORATORY);
        response.setData(laboratoryByTypeList);
        return response;
    }

    @RequestMapping(value = "/scientificInstitutions")
    public Response<Object> scientificInstitutions(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "衡水市科研机构总数（渗透）");
        List<ScientificByType> organizationList  = orgServiceImpl.getScientificByType(SystemConstants.LAB_TYPE_SCIENTIFIC);
        response.setData(organizationList);
        return response;
    }

    @RequestMapping(value = "/getOrganizationByDistribution")
    public Response<Object> getOrganizationByDistribution(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "检验中心、实验室、科研机构区域分布");
        List<OrganizationByDistribution>  list = orgServiceImpl.getOrganizationByDistribution();
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getOrgListByZoneCode")
    public Response<Object> getOrgListByZoneCode(HttpServletRequest request){
        Response<Object> response = null;
        response = new Response<Object>(200, "根据区划代码获得机构列表");
        List<Organization> list = orgServiceImpl.getOrgListByZoneCode(request.getParameter("county"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getOrgListByOrganiseZoneCode")
    public Response<Object> getOrgListByOrganiseZoneCode(HttpServletRequest request){
        Response<Object> response = null;
        response = new Response<Object>(200, "根据区划代码和组织代码获得机构列表");
        List<Organization> list = orgServiceImpl.getOrgListByOrganiseZoneCode(request.getParameter("county"), request.getParameter("code"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getOrgTestListByOrganiseZoneCode")
    public Response<Object> getOrgTestListByOrganiseZoneCode(HttpServletRequest request){
        Response<Object> response = null;
        response = new Response<Object>(200, "根据区划代码和组织代码获得检验机构列表");
        List<OrgTest> list = orgServiceImpl.getOrgTestListByOrganiseZoneCode(request.getParameter("county"), request.getParameter("code"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/orgRankNewCancelDistribution")
    public Response<Object> orgRankNewCancelDistribution(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "新增注销机构排名");
        List<RankingByDistribution> list = orgServiceImpl.getNewCancelSumByDistribution();
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getNewCancelSumProportion")
    public Response<Object> getNewCancelSumProportion(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "新增注销机构行业占比");
        List<ProportionByDistribution> list = orgServiceImpl.getNewCancelSumProportion();
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getOrgOrganiseSum")
    public Response<Object> getOrgOrganiseSum(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "安组织类型区分区县机构数");
        List<OrganiseByDistribution> list = orgServiceImpl.getOrgOrganiseSum(request.getParameter("county"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getOrgChildOrganiseSum")
    public Response<Object> getOrgChildOrganiseSum(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "安子组织类型区分区县机构数");
        List<OrganiseByDistribution> list = orgServiceImpl.getOrgChildOrganiseSum(request.getParameter("county"),request.getParameter("parentId"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getNewOrgOrganiseSum")
    public Response<Object> getNewOrgOrganiseSum(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "安组织类型区分区县新增机构数");
        List<OrganiseByDistribution> list = orgServiceImpl.getNewOrgOrganiseSum(request.getParameter("county"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getNewOrgChildOrganiseSum")
    public Response<Object> getNewOrgChildOrganiseSum(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "安子组织类型区分区县新增机构数");
        List<OrganiseByDistribution> list = orgServiceImpl.getNewOrgChildOrganiseSum(request.getParameter("county"),request.getParameter("parentId"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getCancelOrgOrganiseSum")
    public Response<Object> getCancelOrgOrganiseSum(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "安组织类型区分区县注销机构数");
        List<OrganiseByDistribution> list = orgServiceImpl.getCancelOrgOrganiseSum(request.getParameter("county"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getCancelOrgChildOrganiseSum")
    public Response<Object> getCancelOrgChildOrganiseSum(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "安子组织类型区分区县注销机构数");
        List<OrganiseByDistribution> list = orgServiceImpl.getCancelOrgChildOrganiseSum(request.getParameter("county"),request.getParameter("parentId"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getTestOrgOrganiseSum")
    public Response<Object> getTestOrgOrganiseSum(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "安组织类型区分区县检验机构数");
        List<OrganiseByDistribution> list = orgServiceImpl.getTestOrgOrganiseSum(request.getParameter("county"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getTestOrgChildOrganiseSum")
    public Response<Object> getTestOrgChildOrganiseSum(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "安子组织类型区分区县检验机构数");
        List<OrganiseByDistribution> list = orgServiceImpl.getTestOrgChildOrganiseSum(request.getParameter("county"),request.getParameter("parentId"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getOrgTurnoverByIndeustry")
    public Response<Object> getOrgTurnoverByIndeustry(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "衡水十大特色行业分布机构数、营业额");
        List<TurnoverByIndeustry> list = orgServiceImpl.getOrgTurnoverByIndeustry(request.getParameter("county"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getOrgTradeSumByZoneCode")
    public Response<Object> getOrgTradeSumByZoneCode(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "所有机构的主营产业占比");
        List<OrgTradeSum> list = orgServiceImpl.getOrgTradeSumByZoneCode(request.getParameter("county"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getOrgGDPSumByZoneCode")
    public Response<Object> getOrgGDPSumByZoneCode(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "产业GDP占比");
        List<OrgGDPSum> list = orgServiceImpl.getOrgGDPSumByZoneCode(request.getParameter("county"));
        response.setData(list);
        return response;
    }

    @RequestMapping(value = "/getNewOrgOrganiseByZoneCode")
    public Response<Object> getNewOrgOrganiseByZoneCode(HttpServletRequest request) {
        Response<Object> response = null;
        response = new Response<Object>(200, "新增机构类型分布");
        Map map  = orgServiceImpl.getNewOrgOrganiseByZoneCode(request.getParameter("county"),request.getParameter("organiseCode"));
        response.setData(map);
        return response;
    }

}